#include <iostream>
#include <vector>
#include <string>

using namespace std;

string solveEquation(string equation) {
    int n = 0, x = 0, e = equation.find("="), signal = equation[0] == '-' ? -1 : 1, pre = signal == 1 ? 0 : 1;
    for(int i = pre; i < e; i++){
        while(equation[i] != '+' && equation[i] != '-' && i < e) i++;
        string value = equation.substr(pre, i - pre);
        if(value[value.size()-1] != 'x'){
            n += signal * stoi(value);
        }else{
            x += signal * (value.size() == 1 ? 1 : stoi(value.substr(0, value.size()-1)));
        }
        signal = equation[i] == '-' ? -1 : 1;
        pre = i + 1;
    }
    signal = equation[pre] == '-' ? -1 : 1; pre += signal == 1 ? 0 : 1;
    for(int i = pre; i < equation.size(); i++){
        while(equation[i] != '+' && equation[i] != '-' && i < equation.size()) i++;
        string value = equation.substr(pre, i - pre);
        if(value[value.size()-1] != 'x'){
            n -= signal * stoi(value);
        }else{
            x -= signal * (value.size() == 1 ? 1 : stoi(value.substr(0, value.size()-1)));
        }
        signal = equation[i] == '-' ? -1 : 1;
        pre = i + 1;
    }
    if(x != 0 && n % x == 0){
        return "x=" + to_string(-n/x);
    }else if(x == 0 && n != 0){
        return "No solution";
    }else{
        return "Infinite solutions";
    }
}

int main(){
    string equation = "-2x+5-3+x=6+x-2";
    cout << solveEquation(equation) << endl;
    return 0;
}
